package com.jrx.anytxn.param.config;

import com.jrx.anytxn.common.uitl.DateUtils;
import com.jrx.anytxn.common.uitl.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Date;

/**
 * 对账文件读取相关配置
 * @author zcc
 */
@Component
@ConfigurationProperties(prefix = "billcompare.file")
public class BillCompareConfig {

    /**
     * 文件路径
     */
    private String filePath;
    /**
     * 兴安借文件路径
     */
    private String xajFilePath;
    /**
     * 循环读取次数
     */
    private Integer readCount;

    /**
     * 读取周期-毫秒
     */
    private Integer readPeriod;

    /**
     * 联盟支付云平台-成员行号
     */
    private String payBankId;

    /**
     * 联盟支付云平台-商户号
     */
    private String payBusinessId;

    /**
     * 代付文件对账
     */
    private String compareFK;

    /**
     * 代收文件对账
     */
    private String compareHK;

    private String thirdChannel;

    /**
     * 指定对账日期
     */
    private String today;
    /**
     * 获取指定对账日期
     *
     * @return today
     */
    public Date getToday() {
        return DateUtils.parseDate(this.today, DateUtils.DATE_PATTERN_ANOTHER);
    }

    /**
     * 设置指定对账日期
     *
     * @param today
     */
    public void setToday(String today) {
        this.today = today;
    }

    public String getFilePath() {
        boolean contains = Arrays.asList("PCP", "T24").contains(thirdChannel);
        if (StringUtils.isNotBlank(this.thirdChannel) && contains) {
            this.filePath = this.xajFilePath;
        }

        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public Integer getReadCount() {
        return readCount;
    }

    public void setReadCount(Integer readCount) {
        this.readCount = readCount;
    }

    public Integer getReadPeriod() {
        return readPeriod;
    }

    public void setReadPeriod(Integer readPeriod) {
        this.readPeriod = readPeriod;
    }

    public String getPayBankId() {
        return payBankId;
    }

    public void setPayBankId(String payBankId) {
        this.payBankId = payBankId;
    }

    public String getPayBusinessId() {
        return payBusinessId;
    }

    public void setPayBusinessId(String payBusinessId) {
        this.payBusinessId = payBusinessId;
    }

    public String getCompareFK() {
        return compareFK;
    }

    public void setCompareFK(String compareFK) {
        this.compareFK = compareFK;
    }

    public String getCompareHK() {
        return compareHK;
    }

    public void setCompareHK(String compareHK) {
        this.compareHK = compareHK;
    }

    public String getThirdChannel() {
        return thirdChannel;
    }

    public void setThirdChannel(String thirdChannel) {
        this.thirdChannel = thirdChannel;
    }

    /**
     * 获取 兴安借文件路径
     *
     * @return xajFilePath 兴安借文件路径
     */
    public String getXajFilePath() {
        return this.xajFilePath;
    }

    /**
     * 设置 兴安借文件路径
     *
     * @param xajFilePath 兴安借文件路径
     */
    public void setXajFilePath(String xajFilePath) {
        this.xajFilePath = xajFilePath;
    }
}